<?php
/**
 * Main Ressource SpreadSheet
 * This page display on the left a menu and on the right the content
 * of the page
 *
 * @author Xavier VILAIN
 * @package contacts
 */
use Fox\Html\Html;
use Shama\Messages;
use Fox\Html\Screen\Container;
use Fox\Core\Errors;
use Fox\Generator;
use Fox\Html\Navigation\Menu\Item;
use Fox\Html\Navigation\Menu\Item\Sub;
use Fox\Html\Navigation\Menu;

$xview = Xview::instance();
$id = $xview->val("inLineId");
$page = $xview->val("page","newsfeed");
$module = $xview->currentModule();
$action = $xview->currentAction();

$contact = $xview->component('contacts','contact');
$companyPartner = $contact->company();

$container = new Container('contact','contacts','newsfeed');
// Contact Summary
$contactMenu = new Menu("leftMenu",Msg(Messages::BUNDLE,Messages::LABEL_CONTACT));

// News Feed
$contactMenu->add(new Item("newsfeed",Msg(Messages::BUNDLE,Messages::LABEL_NEWSFEED),
						Generator::url($module,'newsfeed',null,
							array('inLineId' => $id))
						));//@TODO fill with the last changes
// Personnal Information
$contactMenu->add(new Item("personnal",Msg(Messages::BUNDLE,Messages::LABEL_PERSONAL_DATA),
						Generator::url($module,'personnal',null,
							array('inLineId' => $id))
						));

// Partners
$contactMenu->add(new Item("partners",Msg(Messages::BUNDLE,Messages::LABEL_PARTNERS),
						Generator::url($module,'partners',null,
							array('inLineId' => $id)),
					$contact->countPartners()
					));
// Tasks
$contactMenu->add(new Item("tasks",Msg(Messages::BUNDLE,Messages::LABEL_TASKS),
						Generator::url($module,'tasks',null,
							array('inLineId' => $id)),
					$contact->countTasks()
					));
$summary = null;
if(!empty($companyPartner))
{
	$summary .= '<div>'.$companyPartner->company()->name1.'</div>';
}
// Build Summary Box
$html = '<div class="summaryBox">
				<a href="?mod=contacts&act=main&inLineId='.$id.'" class="slink">
					<span class="title">'.$contact->name1.'</span>
				</a>
				<div class="i">
					<span >'.$contact->function.'</span>
				</div>
				<div>'.$summary.'</div>
			</div>';
$container->left()->add(new Html('summary',$html));
$container->left()->add($contactMenu);
// Select Clicked Item
$container->left()->item($page)->selected();
echo $container->render();